from numpy import kaiser
import ars_parse
import socket
import struct
UDP_IP = "127.0.0.1"
UDP_PORT = 53349

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))



data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print("received message: %s" % data)

kaitai = ars_parse.ArsParse.from_bytes(data)
# kaitai.from_bytes(data)
print(kaitai.header.method_id)
print(kaitai.header.length)
print(kaitai.header.protocol_version)

# # save data
# pack_data = struct.pack('x',data)
# 这里 b 是 二进制模式  
f = open("bytedata.bin",'wb')
f.write(data)